package com.ai;
import kafka.producer.Partitioner;
import kafka.utils.VerifiableProperties;

import java.util.Random;
public class Perfermanceartitioner<T> implements Partitioner {
    public Perfermanceartitioner(VerifiableProperties props) {
    }
    @Override
    public int partition(Object obj, int numPartitions) {
        if(obj == null){
            Random random = new Random();
            System.out.println("key is null ");
            return random.nextInt(numPartitions);
        }
        else {
            long partitionNum = obj.hashCode();
            int result = (int)partitionNum%numPartitions;
            return result;
        }
    }


}